<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('用户注销商铺')"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-ShopOffUser-add">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">注销原因：</label>
            <div class="col-sm-8">
                <textarea name="offReason" class="form-control" required></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">上传凭证：</label>
            <div class="col-sm-8">
                <input id="manyFiles" class="file" type="file" multiple
                       data-allowed-file-extensions='["png", "jpeg", "gif", "jpg"]' data-max-file-count="5">
            </div>
        </div>
    </form>
</div>
<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>提 交
        </button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭
        </button>
        <button type="button" class="btn btn-sm btn-warning" onclick="offHistory()"><i class="fa fa-search"></i>注销记录
        </button>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script type="text/javascript">
    var prefix = ctx + "ShopOffUser/ShopOffUser";
    $("#form-ShopOffUser-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        $.get(prefix + "/queryOffShop", function (res) {
            if (res == 0){
                if ($.validate.form()) {
                    var formData = new FormData($("#form-ShopOffUser-add")[0]);
                    if ($('#manyFiles')[0].files.length > 0) {
                        for (var i = 0; i < $('#manyFiles')[0].files.length; i++) {
                            formData.append('manyFiles', $('#manyFiles')[0].files[i]);
                        }
                    } else {
                        $.modal.alertWarning("缺少文件")
                        return false;
                    }
                    $.ajax({
                        url: prefix + "/add",
                        type: 'post',
                        cache: false,
                        data: formData,
                        processData: false,
                        contentType: false,
                        dataType: "json",
                        success: function (result) {
                            $.operate.successCallback(result);
                        }
                    });
                }
            } else {
                $.modal.alertWarning("请耐心等待上次审核结果")
            }
        });
    }
    function offHistory() {
        $.get(ctx+"/WxShop/WxShop/selectShopId",function (shopId) {
            var url=ctx+"WxShop/WxShop/lookHistory/"+shopId+"/4";
            $.modal.openTab("注销记录",url);
        })
    }

</script>
</body>
</html>